package com.itrip.utils;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class RegisterMsg {

    public static String send(String phone,Integer code) throws ClientException {
        String accessKeyId = "LTAI4G9Y5xva11GSpTPH783d";
        String accessSecret = "9rPkHnQINDAtwe2KGwCppumas05L3K";

        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessSecret);
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", phone);
        request.putQueryParameter("SignName", "学涯ABC");
        request.putQueryParameter("TemplateCode", "SMS_197895649");
        request.putQueryParameter("TemplateParam", "{'code':'"+code+"'}");
        CommonResponse response = client.getCommonResponse(request);
        return response.getData();
    }
}
